package com.my.code.pool;

import java.util.Random;
import java.util.concurrent.TimeUnit;

public class TestThreadPool {

    //private static final ExecutorService executorService = Executors.newFixedThreadPool(2);

    public static void main(String[] args) {
        Random r = new Random();
        for (int i = 0; i < 1000; i++) {
            ThreadPoolUtil.getPool().submit(() -> {
                try {
                    TimeUnit.MILLISECONDS.sleep(r.nextInt(500));
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("i am " + Thread.currentThread().getName());
            });
            if (i%10==0) System.out.println("i = " + i);
        }
    }
}
